package com.example.ssm.test;


import java.util.Random;

/**
 * Created by Intellij IDEA.
 * User: JonnyJiang
 * Date: 2021/6/10
 */
public class CodeDemo {
    public static void main(String[] args) {

        CodeDemo codeDemo = new CodeDemo();
        Random random = new Random();

        for (int i = 0; i < 1000; i++) {
            int num = (int)(Math.random() * 10);
            String gender = num % 2 == 0?"女":"男";
            System.out.println(codeDemo.generateName(random)+"\t"+codeDemo.generatePhone()+"\t"+gender+"\t"+(num % 5));

        }
    }


    public String generateName(Random random) {
        char start = '\u4e00';
        int charNum = Integer.valueOf('\u9fa5') - Integer.valueOf('\u4e00');
        StringBuilder name = new StringBuilder();
        int length = (int) (Math.random() * 10 % 4 + 2);
        for (int i = 0; i < length; i++) {

            int step = random.nextInt(10000);
            if (step < 0) {
                continue;
            }
            name.append((char) (start + step));
        }

        return String.valueOf(name);
    }

    public String generatePhone() {
        int num = (int) (Math.random() * 10);

        StringBuilder phone = new StringBuilder();
        switch (num % 4) {
            case 0:
                phone.append("13");
                break;
            case 1:
                phone.append("14");
                break;
            case 2:
                phone.append("15");
                break;
            case 3:
                phone.append("18");
                break;
        }

        for (int j = 0; j < 9; j++) {
            phone.append((int) (Math.random() * 10));
        }

        return String.valueOf(phone);
    }

}
